/*
 * MusicLabs, Copyright (C) 2008-2009 Felippe Ragghianti
 * http://code.google.com/p/musiclabs
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 */


package br.com.music.scale;

import br.com.music.Interval;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import br.com.music.Pitch;

/**
 *  The {@link CromaticScale} has all semitones within the spectrum of a scale.
 *
 * @version $LastChangedRevision$
 */
public class CromaticScale extends Scale {

    static {
        /**
         * The cromatic scale has every semiton within a field.
         */
        CromaticScale.intervals = Arrays.asList( new Interval[]{
            Interval.SEMITONE, Interval.SEMITONE, Interval.SEMITONE,
            Interval.SEMITONE, Interval.SEMITONE, Interval.SEMITONE,
            Interval.SEMITONE, Interval.SEMITONE, Interval.SEMITONE,
            Interval.SEMITONE, Interval.SEMITONE, Interval.SEMITONE
        });
    }

    /**
     * Class constructor.
     *
     * @param tonic Scale's tonic (root note).
     */
    public CromaticScale(Pitch tonic) {
        super(tonic);
    }

    /**
     * Create sale.
     *
     * @return List of notes encompassed by this {@link Scale}.
     */
    @Override
    protected List<Pitch> createScale() {
        List<Pitch> cromaticScale = new ArrayList<Pitch>(Arrays.asList(Pitch.values()));
        Collections.rotate(cromaticScale, cromaticScale.size() - cromaticScale.indexOf(this.tonic));
        cromaticScale.add(cromaticScale.get(0));
        return cromaticScale;
    }
}
